<?xml version="1.0" encoding="UTF-8"?>
<jasperReport xmlns="http://jasperreports.sourceforge.net/jasperreports" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports http://jasperreports.sourceforge.net/xsd/jasperreport.xsd" name="null" pageWidth="595" pageHeight="842" whenNoDataType="AllSectionsNoDetail" columnWidth="535" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" resourceBundle="ru/apertum/qsystem/reports/templates/i3-label-rep" isIgnorePagination="true" uuid="7e4c641d-e3b3-4ee9-95c5-fbbe4a55e867">
	<property name="ireport.zoom" value="1.0"/>
	<property name="ireport.x" value="0"/>
	<property name="ireport.y" value="0"/>
	<parameter name="sd" class="java.util.Date"/>
	<parameter name="ed" class="java.util.Date"/>
	<parameter name="ed1" class="java.util.Date"/>
	<queryString language="SQL">
		<![CDATA[SELECT
   CONCAT(sr.name, ' \n ', ROUND((
         (SELECT CAST(  count(*)   AS DECIMAL(7,5)) 
        FROM
             services sr1 JOIN statistic st1 ON   st1.state_in<>0 AND    sr1.id = st1.service_id
        WHERE
             st1.client_stand_time >= $P{sd} and
             st1.client_stand_time <= $P{ed1} and
             sr1.name = sr.name )
         /
        ( (SELECT count(*)
        FROM
             services sr1 JOIN statistic st1 ON    st1.state_in<>0 AND   sr1.id = st1.service_id
        WHERE
             st1.client_stand_time >= $P{sd} and
             st1.client_stand_time <= $P{ed1} )) * 100
                                        ), 1), '%') as service_name,
   (SELECT count(*)
        FROM
             services sr1 JOIN statistic st1 ON   st1.state_in<>0 AND    sr1.id = st1.service_id
        WHERE
             st1.client_stand_time >= $P{sd} and
             st1.client_stand_time <= $P{ed1}) as client_count
FROM
   services sr JOIN statistic st ON   st.state_in<>0 AND   sr.id = st.service_id
WHERE
   st.client_stand_time >= $P{sd} and
   st.client_stand_time <= $P{ed1}]]>
	</queryString>
	<field name="service_name" class="java.lang.String">
		<fieldDescription><![CDATA[]]></fieldDescription>
	</field>
	<field name="client_count" class="java.lang.Long"/>
	<variable name="totalServices" class="java.lang.Integer" resetType="Group" resetGroup="modelGroup" calculation="Count">
		<variableExpression><![CDATA[$F{service_name}]]></variableExpression>
		<initialValueExpression><![CDATA[new java.lang.Integer(0)]]></initialValueExpression>
	</variable>
	<group name="modelGroup">
		<groupExpression><![CDATA[$F{service_name}]]></groupExpression>
	</group>
	<title>
		<band height="58">
			<line>
				<reportElement uuid="af404fa8-48cc-4f8f-94c7-6340df477c83" x="0" y="8" width="555" height="1"/>
			</line>
			<line>
				<reportElement uuid="6f583b55-4997-4e94-878e-424ab6d33511" positionType="FixRelativeToBottom" x="0" y="57" width="555" height="1"/>
			</line>
			<textField>
				<reportElement uuid="881ab079-9c5e-43b6-92c7-d13e46c044b3" x="1" y="9" width="554" height="48"/>
				<textElement textAlignment="Center" verticalAlignment="Middle">
					<font size="18" isBold="true" pdfFontName="tahoma.ttf" pdfEncoding="KOI8-R" isPdfEmbedded="true"/>
				</textElement>
				<textFieldExpression><![CDATA[$R{ratio_period_services}+"\n"+
$R{from_date}+" " + (new java.text.SimpleDateFormat("dd.MM.yyyy")).format($P{sd}) +
" "+$R{to_date}+" " + (new java.text.SimpleDateFormat("dd.MM.yyyy")).format($P{ed})]]></textFieldExpression>
			</textField>
		</band>
	</title>
	<pageFooter>
		<band height="21">
			<textField evaluationTime="Report" pattern="" isBlankWhenNull="false">
				<reportElement uuid="c3a8f8ea-0eab-4fcb-89c2-8c05933cc497" key="textField" x="516" y="2" width="36" height="19" forecolor="#000000" backcolor="#FFFFFF"/>
				<box>
					<topPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
					<leftPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
					<bottomPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
					<rightPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
				</box>
				<textElement>
					<font size="10"/>
				</textElement>
				<textFieldExpression><![CDATA["" + $V{PAGE_NUMBER}]]></textFieldExpression>
			</textField>
			<textField pattern="" isBlankWhenNull="false">
				<reportElement uuid="4846023e-a56e-4d31-bbbb-362d24e7439f" key="textField" x="197" y="2" width="315" height="19" forecolor="#000000" backcolor="#FFFFFF"/>
				<box>
					<topPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
					<leftPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
					<bottomPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
					<rightPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
				</box>
				<textElement textAlignment="Right">
					<font size="10" pdfFontName="tahoma.ttf" pdfEncoding="KOI8-R" isPdfEmbedded="true"/>
				</textElement>
				<textFieldExpression><![CDATA[$R{page}+" " + $V{PAGE_NUMBER} + " "+$R{from}+" "]]></textFieldExpression>
			</textField>
			<textField pattern="" isBlankWhenNull="false">
				<reportElement uuid="e51260f7-852a-494b-baa3-c01b3631ff60" key="textField" x="1" y="2" width="143" height="19" forecolor="#000000" backcolor="#FFFFFF"/>
				<box>
					<topPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
					<leftPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
					<bottomPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
					<rightPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
				</box>
				<textElement>
					<font size="10"/>
				</textElement>
				<textFieldExpression><![CDATA[new Date()]]></textFieldExpression>
			</textField>
		</band>
	</pageFooter>
	<summary>
		<band height="630">
			<pieChart>
				<chart evaluationTime="Report">
					<reportElement uuid="f861dc29-a4f7-400d-b639-4876a13ce279" key="" stretchType="RelativeToBandHeight" x="1" y="29" width="554" height="601"/>
					<chartTitle/>
					<chartSubtitle/>
					<chartLegend/>
				</chart>
				<pieDataset>
					<keyExpression><![CDATA[$F{service_name}]]></keyExpression>
					<valueExpression><![CDATA[$V{totalServices}]]></valueExpression>
				</pieDataset>
				<piePlot isCircular="true">
					<plot/>
					<itemLabel/>
				</piePlot>
			</pieChart>
			<textField>
				<reportElement uuid="f49e929c-b2c1-4e14-bce4-04d1a54adfb4" x="1" y="9" width="554" height="20"/>
				<textElement>
					<font pdfFontName="tahoma.ttf" pdfEncoding="KOI8-R" isPdfEmbedded="true"/>
				</textElement>
				<textFieldExpression><![CDATA[$R{clients_total}+": "+$F{client_count}]]></textFieldExpression>
			</textField>
		</band>
	</summary>
</jasperReport>
